/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package scapi.utilerias;

import com.jidesoft.icons.IconSet.File;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
import sun.java2d.pipe.SpanShapeRenderer.Simple;

/**
 *
 * @author emmanuel
 */
public class SesionManager {

    public static void printIDSession(String nomUsuario) throws IOException{
       SimpleDateFormat fecha = new SimpleDateFormat("yyyy-MM-dd");
       String fec = fecha.format(new Date());
       Random r = new Random(20);

       String sessionID = fec+nomUsuario+r.nextInt();
       FileWriter fw = new FileWriter("session.txt");
       fw.write(sessionID);
       fw.close();

    }

    public static String getIDSession() throws FileNotFoundException, IOException{
        FileReader fr = new FileReader("session.txt");
        BufferedReader br = new BufferedReader(fr);

        String sessionID = br.readLine();

        br.close();
        fr.close();

        return sessionID;



    }

    public static void main(String args[]){
        try {
            SesionManager.printIDSession("jsus");
        } catch (IOException ex) {
            Logger.getLogger(SesionManager.class.getName()).log(Level.SEVERE, null, ex);
        }
    }



}
